﻿using System;
using IFDB.Models;
using IFDB.Models.Contexts;

namespace IFDB.Repositories.Foundation
{
    public abstract class Repository
    {
        public Repository(IFDBContext db)
        {
            if (db == null)
                throw new ArgumentNullException("context");

            this.db = db;
        }

        protected IFDBContext db;

        public void Save()
        {
            db.SaveChanges();
        }

        protected static DateTime GetStartOfDay(DateTime value)
        {
            return value.Date;
        }

        protected static DateTime GetEndOfDay(DateTime value)
        {
            return value.Date.AddDays(1).AddMilliseconds(-1);
        }
    }
}
